
var express = require("express");
var bodyParser = require('body-parser');
var multiparty = require('multiparty');
var path = require('path');
var cookieParser = require('cookie-parser');
var session = require('express-session');

var sql = require('./db/mysql');
var app = express();
var userRouter = require('./routers/user');
var articleRouter = require('./routers/articleManagement');

app.use(express.static(__dirname + '/public'));
app.use(bodyParser.json({limit: '50mb'}));
app.use(bodyParser.urlencoded({
 limit: '50mb',
 extended:true
}));

app.use(cookieParser('sessiontest'));
app.use(session({
    secret: 'sessiontest',//与cookieParser中的一致
    resave: true,
    saveUninitialized:true
}));


// 允许跨域请求
app.all('*', function(req, res, next) {
   res.header("Access-Control-Allow-Origin", "*");
   res.header("Access-Control-Allow-Headers", "X-Requested-With");
   res.header("Access-Control-Allow-Methods","PUT,POST,GET,DELETE,OPTIONS");
   res.header("X-Powered-By",' 3.2.1');
   res.header("Content-Type", "application/json;charset=utf-8");
   next();
});

//登录注册用户接口
app.use("/user", userRouter);
app.use('/articleManagement', articleRouter);
app.listen("8088", ()=>{
	console.log("start scc");
})


